package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.List;

import com.xcity.db.entity.Mine;
import com.xcity.game.common.EasyItemInfo;
import com.xcity.game.map.MapService;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class MineDetailResponse extends Response {

	private int map;
	private int pos;
	private long ownerId;
	private int mineType;
	
	private int leftSecond;
	private int extendCount;
	private String ownerIcon;
	private String name;
	private int level;
	private int vipLevel;
	
	private int costStone;
	private int costStr;
	
	private int money;
	private List<EasyItemInfo> items;
	private long fightValue;
	
	public MineDetailResponse(int serial, Mine mine, long now) {
		super(serial);
		map = mine.getMap();
		pos = mine.getPos();
		ownerId = mine.getOwnerId();
		mineType = mine.getMineType();
		
		leftSecond = (int) ((mine.getTakeTime() + (mine.getExtendCount()) * MapService.TAKE_MAX_DURATION - now) / 1000L);
		if(leftSecond < 0){
			leftSecond = 0;
		}
		this.extendCount = mine.getExtendCount() - 1;
		
		this.level = mine.getOwnerLevel();
		this.vipLevel = mine.getOwnerVipLevel();
		this.ownerIcon = mine.getOwnerIcon();
		this.name = mine.getOwnerName();
		
		costStone = mine.getTypeTemp().getCostStone();
		costStr = mine.getTypeTemp().getCostStr();
		
		int count = MapService.TAKE_MAX_DURATION / MapService.GET_MONEY_DURATION;
		money = mine.getTypeTemp().getProduceGold() * count;
		items = new ArrayList<EasyItemInfo>();
		for(int i = 0, size = mine.getTypeTemp().getProduceItem().length; i < size; i++){
			EasyItemInfo item = new EasyItemInfo(mine.getTypeTemp().getProduceItem()[i], mine.getTypeTemp().getProduceItemCount()[i] * count);
			items.add(item);
		}
		fightValue = mine.getFightValue();
	}

	public int getMap() {
		return map;
	}

	public void setMap(int map) {
		this.map = map;
	}

	public int getPos() {
		return pos;
	}

	public void setPos(int pos) {
		this.pos = pos;
	}

	public long getOwnerId() {
		return ownerId;
	}

	public void setOwnerId(long ownerId) {
		this.ownerId = ownerId;
	}

	public int getMineType() {
		return mineType;
	}

	public void setMineType(int mineType) {
		this.mineType = mineType;
	}

	public int getLeftSecond() {
		return leftSecond;
	}

	public void setLeftSecond(int leftSecond) {
		this.leftSecond = leftSecond;
	}

	public int getExtendCount() {
		return extendCount;
	}

	public void setExtendCount(int extendCount) {
		this.extendCount = extendCount;
	}

	public String getOwnerIcon() {
		return ownerIcon;
	}

	public void setOwnerIcon(String ownerIcon) {
		this.ownerIcon = ownerIcon;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getLevel() {
		return level;
	}

	public void setLevel(int level) {
		this.level = level;
	}

	public int getVipLevel() {
		return vipLevel;
	}

	public void setVipLevel(int vipLevel) {
		this.vipLevel = vipLevel;
	}

	public int getCostStone() {
		return costStone;
	}

	public void setCostStone(int costStone) {
		this.costStone = costStone;
	}

	public int getCostStr() {
		return costStr;
	}

	public void setCostStr(int costStr) {
		this.costStr = costStr;
	}

	public int getMoney() {
		return money;
	}

	public void setMoney(int money) {
		this.money = money;
	}

	public List<EasyItemInfo> getItems() {
		return items;
	}

	public void setItems(List<EasyItemInfo> items) {
		this.items = items;
	}

	public long getFightValue() {
		return fightValue;
	}

	public void setFightValue(long fightValue) {
		this.fightValue = fightValue;
	}
	
}
